namespace Tnelab{
    export class TneXMLHttpRequest {
        private xhr: XMLHttpRequest;
        public constructor() {
            this.xhr = new XMLHttpRequest();
            this.xhr.responseType = "arraybuffer";
        }
        public Send(url: string, datas: Uint8Array): Promise<ArrayBuffer> {
            return new Promise((resolve, reject) => {
                this.xhr.onload = () => {
                    let buffer = this.xhr.response as ArrayBuffer;
                    resolve(buffer);
                    //this.xhr.abort();
                }
                this.xhr.open("post", url, true);
                this.xhr.setRequestHeader("Content-Type", "application/octet-stream");
                this.xhr.send(datas);
            });
        }
    }
}
